﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace KD.Sms
{
    public partial class frmCommonConfigLone : Form
    {
        public short E_Value { set; get; }
        public frmCommonConfigLone()
        {
            InitializeComponent();
        }

        public frmCommonConfigLone(string title)
        {
            InitializeComponent();
            labTitle.Text = title + ":";
        }

        private void btnSet_Click(object sender, EventArgs e)
        {
            E_Value = short.Parse(txtValue.Text);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void txtValue_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
            {
                e.Handled = true;//消除不合适字符
            }
            else if (Char.IsPunctuation(e.KeyChar))
            {
                if (e.KeyChar != '.' || this.txtValue.Text.Length == 0)//小数点
                {
                    e.Handled = true;
                }
                if (txtValue.Text.LastIndexOf('.') != -1)
                {
                    e.Handled = true;
                }
            }
        }

        private void frmCommonConfigLone_Load(object sender, EventArgs e)
        {

        }
    }
}
